package com.tac.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesReaderUtil {
    public static Properties propertiesReader(String propertiesUrl) {
        Properties prop = new Properties();//java提供的读取properties的类
        InputStream input = null;
        try { //"src\\main\\resources\\com\\tac\\login\\config.properties"
            input = new FileInputStream(propertiesUrl);//从根目录开始读
            // 加载properties文件
            prop.load(input);
            // 根据属性名获取属性值
//            String http = prop.getProperty("http");
//            String business = prop.getProperty("business");
//            System.out.println("数据库用户名: " + http);
//            System.out.println("数据库密码: " + business);
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return prop;
        }
    }
}
